<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="cn.firstsoft.firstframe.util.AuthUtils"%>
<%@ include file="/common/taglibs2.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<fmt:message key="header_top_label1" var="header_top_label1"/>

<fmt:message key="portal_header_top_label1" var="portal_header_top_label1"/>
<fmt:message key="portal_header_top_label2" var="portal_header_top_label2"/>
<fmt:message key="portal_header_top_label3" var="portal_header_top_label3"/>
<fmt:message key="portal_header_top_label4" var="portal_header_top_label4"/>
<fmt:message key="portal_header_top_label5" var="portal_header_top_label5"/>
<fmt:message key="portal_header_top_label6" var="portal_header_top_label6"/>
<fmt:message key="portal_header_top_label7" var="portal_header_top_label7"/>
<fmt:message key="portal_header_top_label8" var="portal_header_top_label8"/>
<fmt:message key="portal_header_top_label9" var="portal_header_top_label9"/>
<fmt:message key="portal_header_top_label10" var="portal_header_top_label10"/>
<fmt:message key="portal_header_top_label11" var="portal_header_top_label11"/>
<fmt:message key="portal_header_top_label12" var="portal_header_top_label12"/>
<fmt:message key="portal_header_top_label13" var="portal_header_top_label13"/>
<fmt:message key="portal_header_top_label14" var="portal_header_top_label14"/>
<fmt:message key="common_setting" var="common_setting"/>

<c:set var="eas" value="<%=org.springside.core.Constants.EAS%>" />
<c:if test="${!empty param.portalviewwin}">
<table cellspacing="0" cellpadding="0" style="background: #cecd9c;width:100%;height:40px;border: #f8f235 1px solid;">
	<tr>
		<td align="center"> 
			<a style="position:absolute;z-index:999;text-decoration:none;" href="#" onclick="hideView()">
				<font style="font-weight:bold;font-size:16px;color:red;">${portal_header_top_label14}</font>
			</a>&nbsp;
		</td>
	</tr>
</table>
</c:if>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="52%">
			<table border="0" cellspacing="0" cellpadding="0" width="530">
				<tr>
					<td class="top_logo"></td>
				</tr>
			</table>
		</td>
		<td width="28%" valign="top">
			<table width="100%" border="0" height="33" cellspacing="0" cellpadding="0">
				<tr align="right" valign="middle">
					<td width="50%">
						<%if ("true".equals(org.springside.core.Constants.RTX)) {%>
						<img src="../../images/rtx.png" style="cursor: pointer;width: 16;height: 16;" onclick="open('../../themes/${sessionScope.loginUser.theme}/oaToRtx.jsp','web','width=200,height=100,top=300,left=500')">
						<%} %>
					</td>
					<td width="50%">
						${sessionScope.loginUser.name}&nbsp;&nbsp;<span id="separate_time_span"></span>
					</td>
				</tr>
				<!-- ceo角色才看到天气信息 -->
				<tr align="center">
					<td colspan="2">
						<table id="ceoWeather" style="display: none;" cellspacing="0" cellpadding="0">
							<tr>
								<td>
									<img name="todayPic" src="<%=basePath%>themes/${sessionScope.loginUser.theme}/images/portlet/weather/s_en_big/sunny.png"  style="background-position: -40px,-40px;"/>
								</td>
								<td>
									<div id="today_temperature"></div>
									<div id="today_weatherType"></div>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
		<td width="20%" align="center" valign="top">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr align="center">
					<td class="top_setting_left"></td>
					<td class="top_setting_text" >
					<%int menuTop = 30; 
					  boolean authModulesSetting = AuthUtils.isAuthorized("AUTH_MODULES_SETTING");
					  boolean authModulesWorkflow = AuthUtils.isAuthorized("AUTH_MODULES_WORKFLOW");
					%>
						<ul class="dropdown">
							<li><a href="#">${common_setting}<img id="topSettingArrowImage" src="../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/top_setting_arrowdown.png" border="0"/></a>
								<ul id="_ul">
									<%if(authModulesSetting){  
										menuTop+= 60;
										if(org.springside.core.Constants.EAS.equalsIgnoreCase("false")){
											menuTop+= 60;
									%>
									<c:if test="${!eas}">
										<li><a href="../../modules/setting/user.do?method=modifyInfo">${portal_header_top_label2 }</a></li>
										<li><a href="../../modules/setting/user.do?method=modifyPassword">${portal_header_top_label3 }</a></li>
									</c:if>
										<%} %>
									<li><a href="../../modules/setting/user.do?method=selectMenus" onclick="deleteHeaderTabCookie();">${portal_header_top_label7 }</a></li>
									<li><a href="../../modules/setting/messagesets.do">${portal_header_top_label6 }</a></li>
									<%} %>
									<li><a href="../../modules/portal/page.do?method=portalPersonalIndex&portalwin=true">${portal_header_top_label1 }</a></li>
									<%if(authModulesWorkflow){  menuTop+= 60;%>
									<li><a href="../../modules/setting/workflowShortopinion.do">${portal_header_top_label5 }</a></li>
									<li><a href="../../modules/setting/workflowSignature.do">${portal_header_top_label4 }</a></li>
									<%} %>
									<li><a href="#">&nbsp;&nbsp;${portal_header_top_label8 }&nbsp;<img src="../../themes/mskin/images/calendar_next.gif" border="0"/></a>
										<ul id="changeThemeUL" style="top:<%=menuTop %>px;">
											<li><a href="#" onclick="changeTheme('01')">
													<c:choose>
							              				<c:when test="${sessionScope.loginUser.themePath == '01'}">
							              					&nbsp;<img src="../../images/check.png" style="width: 13px;height: 13px;border: 0px;"/>
							              				</c:when>
							              				<c:otherwise>
							              					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							              				</c:otherwise>
							              			</c:choose>
													${portal_header_top_label9 }
												</a>
											</li>
											
											<li><a href="#" onclick="changeTheme('02')">
													<c:choose>
							              				<c:when test="${sessionScope.loginUser.themePath == '02'}">
							              					&nbsp;<img src="../../images/check.png" style="width: 13px;height: 13px;border: 0px;"/>
							              				</c:when>
							              				<c:otherwise>
							              					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							              				</c:otherwise>
							              			</c:choose>
													${portal_header_top_label10 }
												</a>
											</li>
											<li><a href="#" onclick="changeTheme('03')">
													<c:choose>
							              				<c:when test="${sessionScope.loginUser.themePath == '03'}">
							              					&nbsp;<img src="../../images/check.png" style="width: 13px;height: 13px;border: 0px;"/>
							              				</c:when>
							              				<c:otherwise>
							              					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							              				</c:otherwise>
							              			</c:choose>
													${portal_header_top_label11 }
												</a>
											</li>
											
										</ul>
									</li>
									
								</ul>
							</li>
						</ul>
					
					</td>
					<td class="top_line"></td>
					<td class="top_setting_text">
						<a class="top_exit" href="<c:url value="/j_acegi_logout"/>" onclick="deleteHeaderTabCookie();"><fmt:message key="header_menu_exit" /></a>
					</td>
					<td class="top_setting_right"></td>
                </tr>
            </table>
		</td>
	</tr>
</table>
<script language="javascript">

	var today = null; 
	function startTime()
	{
		today = new Date()
		var h = today.getHours()
		
		if(parseInt(h) < 12){
			jQuery('#separate_time_span').html("${portal_header_top_label12}");
		}else{
			jQuery('#separate_time_span').html("${portal_header_top_label13}");
		}
		today = null; 
		setTimeout('startTime()',500);
	}
	startTime();
	jQuery(function(){
		jQuery("ul.dropdown li").dropdown();
	});

	var topSettingArrowDown = "../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/top_setting_arrowdown.png";
	var topSettingArrowUp = "../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/top_setting_arrowup.png";
	
	jQuery.fn.dropdown = function() {
		addIframe(jQuery('ul:first',this).get(0),jQuery('ul:first',this).width(),jQuery('ul:first',this).height());
		addIframe(jQuery("#changeThemeUL").get(0), jQuery("#changeThemeUL").width(), jQuery("#changeThemeUL").height());
		jQuery(this).hover(function(){
			jQuery('ul:first',this).css('visibility', 'visible');
			jQuery("#topSettingArrowImage").attr('src',topSettingArrowUp);
		},function(){
			jQuery('ul:first',this).css('visibility', 'hidden');
			if(jQuery('ul:first',this).css('visibility') == "hidden" && jQuery('ul:first',this).attr('id') != ""){
				jQuery("#topSettingArrowImage").attr('src',topSettingArrowDown);
			}
		});
	}
	//dexiang_lei 2012-3-22 清除导航的cookie 
	function deleteHeaderTabCookie() {
		if(Get_Cookie("leftMoveTimeCount") != null) {
			Delete_Cookie("leftMoveTimeCount",'/','');
		}
		if(Get_Cookie("rightMoveTimeCount") != null) {
			Delete_Cookie("rightMoveTimeCount",'/','');
		}
	}
</script>
<%-- 
 <TABLE class="header_top_table" border="0" cellpadding="0" cellspacing="0">
 <TR >
	<TD class="logo"><div class="login-logo"></div></TD>
	<td class="header_top_modules_middle" nowrap="nowrap"><fmt:message key="head.welcome" />&nbsp;&nbsp;&nbsp;&nbsp;${sessionScope.loginUser.name}&nbsp;&nbsp;[${sessionScope.loginUser.deptName}]</td>
	<td valign="top">
		<table width="100%" border="0">
          <tr>
          	<td width="15%">
          		<c:if test="${!empty param.portalviewwin}">
				<a style="position:absolute;z-index:999;text-decoration:none;" href="#" onclick="hideView()">
					<font style="font-weight:bold;font-size:16px;color:red;">关闭预览</font>
				</a>
				</c:if>&nbsp;
			</td>
            <td width="85%" align="right">
	            <table width="100%" border="0">
	              <tr>
	              	<td align="right">
	              		<input type="button" onclick="changeTheme('01')"
	              			<c:choose>
	              				<c:when test="${sessionScope.loginUser.themePath == '01'}">
	              					class="blue-Theme-down"
	              				</c:when>
	              				<c:otherwise>
	              					class="blue-Theme-on"
	              				</c:otherwise>
	              			</c:choose>
	              			title="蓝色">
	              		<input type="button" onclick="changeTheme('02')"
	              			<c:choose>
			      				<c:when test="${sessionScope.loginUser.themePath == '02'}">
			      					class="red-Theme-down"
			      				</c:when>
			      				<c:otherwise>
			      					class="red-Theme-on"
			      				</c:otherwise>
			      			</c:choose>
	              			 title="红色">
	              		<input type="button" onclick="changeTheme('03')"
	              			<c:choose>
			      				<c:when test="${sessionScope.loginUser.themePath == '03'}">
			      					class="green-Theme-down"
			      				</c:when>
			      				<c:otherwise>
			      					class="green-Theme-on"
			      				</c:otherwise>
			      			</c:choose>
	              			 title="绿色">
	              	</td>
	
	                <td width="30" align="left"><!--<a href="<c:url value="/help/client.jsp" />" target="_blank" class="link_top">${header_top_label1}</a> --></td>
	                <!-- add by liuzhengwei start 2010-10-09 显示当前在线人数-->
	                 <td width="20" align="right">
	                <%
						if ("true".equals(org.springside.core.Constants.RTX)) {
					%>
	                <img src="../../themes/${sessionScope.loginUser.theme}/skin/01/images/rtx.gif"/>
	                <%} %>
	                </td>
	                <td width="20" align="right">
	                <%
						if ("true".equals(org.springside.core.Constants.RTX)) {
					%>
	                <a  class="link_top" onclick="open('../../themes/${sessionScope.loginUser.theme}/oaToRtx.jsp','web','width=200,height=100,top=300,left=500')" href="#">RTX</a>
	                <%} %>
	                </td>
	                <td width="160" align="right">
	                <c:if test="${isHavePermissionForQuery==0}">
	                <a  class="link_top" href="<c:url value="/modules/checkwork/checkwork.do?method=queryOnlineUsers"/>"><fmt:message key="onlineUser_list_label1" />:<span id="onlineUserCountValue"></span><fmt:message key="onlineUser_list_label4" /></a>
	                </c:if>
	                <c:if test="${isHavePermissionForQuery==1}">
	                <fmt:message key="onlineUser_list_label1" />:<span id="onlineUserCountValue"></span><fmt:message key="onlineUser_list_label4" />
	                </c:if>
	                </td>
	                <td width="10"></td>
	                <!-- add by liuzhengwei 2010-10-09 end-->
	                <td width="20" class="header_logout"></td>
	                <td width="30" align="left"><a  class="link_top" href="<c:url value="/j_acegi_logout"/>"><fmt:message key="header_menu_exit" /></a></td>
	              </tr>
	            </table>
            </td>
          </tr>
          <tr>
            <td align="right" colspan="2">
            <table width="250">
              <tr>
                <td width="86" valign="middle">
                </td>
              </tr>
            </table>
            </td>
          </tr>
        </table>
    </td>
	<TD  width="10">&nbsp;&nbsp;</TD>
 </TR>
 </TABLE>
--%> 
 
 
 
<script type="text/javascript">
//定时查询在线用户数量,如果为0则不定时
var isHavePermissionForQuery = "${isHavePermissionForQuery}";
<%--
//add by liuzhengwei start 2010-10-09 获取当前在线人数
getOnlineUserCount();
function getOnlineUserCount()
{
	var url='<c:url value="/ajaxManager.do?method=ajaxGetOnlineUserCount"/>';
	new Ajax.Request(url, {method: 'post',postBody:'', onSuccess:function(t){
			document.getElementById("onlineUserCountValue").innerText=t.responseText;
		}});
	var time=parseInt(refreshFrequency)*1000;
	if(time!=0)
	{
		window.setTimeout("getOnlineUserCount()",time);
	}
}
//add by liuzhengwei end 2010-10-09 获取当前在线人数
--%>
function changeTheme(val){
	//dexiang_lei 切换皮肤清除cookie
	deleteHeaderTabCookie();
	
	var url='<c:url value="/modules/setting/user.do?method=changeTheme"/>';
	new Ajax.Request(
			url+"&id="+val+"&r="+Math.round(Math.random()*100),
			{method:'get',
			 onComplete:function(data){
					 if(data.responseText == val){
					 //modify by liuzhengwei2011-1-25解决个别路径后面有#号导致换肤没有反应




					 var toUrl=window.location.href;
					 if(toUrl.lastIndexOf('#')!=-1)
					 {
					 	toUrl=toUrl.substring(0,toUrl.length-1);
					 }
					 //dmp:BT522498 增加 refreshFrame参数来区别刷新 by sunyiping 2011-03-18
					 if (toUrl.indexOf("refreshFrame=") < 0){
						 if (toUrl.indexOf("?") > 0){
							 toUrl += "&refreshFrame=";
						 }else{
							 toUrl += "?refreshFrame=";
						 }//end
					 }
					 //window.location.href=toUrl; 
					 //切换皮肤跳到location会有问题，所以统一跳到登录的第一个tab，modify by yuan_zeng 2012-4-13
					 window.location.href='<c:url value="/modules/home/portal.do"/>';
					 }else{alert(data.responseText+'更新失败！请重试');}}
			});
}

function hideView(){
	top.document.getElementById("topDialog").style.display = "none";
	top.document.getElementById("topBlackdiv").style.display = "none";
	top.document.getElementById("topDialogIframe").src = "";
}

function ajaxCEOWeather() {
	new Ajax.Request(
		'<c:url value="/modules/portlet/portletService.do?method=ajaxCEOWeather&openwin=true"/>',
		{
			method: 'post',
			onComplete: countyReturn,
			onFailure: function() {
				alert("ajaxCEOWeather Fail!");
			}
		}	
	);
	 // 回调函数
	 function countyReturn(data) {
		var ceoWeather = document.getElementById("ceoWeather");
		if(data.responseText == 'noCEORole') {
			ceoWeather.style.display = 'none';
		}else {
		   ceoWeather.style.display = 'block';
		   var json = eval("("+data.responseText+")");
		   cityReturn2(json);
		 }
	 }
	 
	String.prototype.replaceAll = function(s1,s2) {
	      return this.replace(new RegExp(s1,"gm"),s2);
	 }
	 
}
 function cityReturn2(data) {
 		//var today_name = document.getElementById("today_name");
		//today_name.innerText = data.name;
		var today_temperature = document.getElementById("today_temperature");
		var temperature = data.temperature;
		temperature = temperature.replaceAll("℃","°");
		today_temperature.innerText = temperature;
		var today_weatherType = document.getElementById("today_weatherType");
		var weatherType = data.weatherType;
		var weatherType_en = data.weatherTypeEn;
		today_weatherType.innerText = weatherType;
		weatherType = weatherType.split("转")[0];
		//图片
		document.images.todayPic.src = '<%=basePath%>' + 'themes\\'+'${sessionScope.loginUser.theme}'+'\\images\\portlet\\weather\\s_en\\'+weatherType_en+'.png';
 }
 //暂时不用ceo预设门户的天气信息
//ajaxCEOWeather();
</script>
